﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class PublicOfficialSelectionModel
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private int _OrgID;
        [DataMember]
        public int OrgID
        {
            get { return _OrgID; }
            set { _OrgID = value; }
        }

        private int _Sec;
        [DataMember]
        public int Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }

        private string _Department;
        [DataMember]
        public string Department
        {
            get { return _Department; }
            set { _Department = value; }
        }

        private string _Duty;
        [DataMember]
        public string Duty
        {
            get { return _Duty; }
            set { _Duty = value; }
        }

        private string _DutyDescription;
        [DataMember]
        public string DutyDescription
        {
            get { return _DutyDescription; }
            set { _DutyDescription = value; }
        }

        private string _PeopleCount;
        [DataMember]
        public string PeopleCount
        {
            get { return _PeopleCount; }
            set { _PeopleCount = value; }
        }

        private string _Education;
        [DataMember]
        public string Education
        {
            get { return _Education; }
            set { _Education = value; }
        }

        private string _Political;
        [DataMember]
        public string Political
        {
            get { return _Political; }
            set { _Political = value; }
        }

        private string _DutyQualifications;
        [DataMember]
        public string DutyQualifications
        {
            get { return _DutyQualifications; }
            set { _DutyQualifications = value; }
        }

        private string _Memo;
        [DataMember]
        public string Memo
        {
            get { return _Memo; }
            set { _Memo = value; }
        }

        private int _Status;
        [DataMember]
        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        private string _CheckMemo;
        [DataMember]
        public string CheckMemo
        {
            get { return _CheckMemo; }
            set { _CheckMemo = value; }
        }

        private bool _IsXDJL;
        [DataMember]
        public bool IsXDJL
        {
            get { return _IsXDJL; }
            set { _IsXDJL = value; }
        }

        private bool _IsJZXXB;
        [DataMember]
        public bool IsJZXXB
        {
            get { return _IsJZXXB; }
            set { _IsJZXXB = value; }
        }

        private string _XBLXString;
        [DataMember]
        public string XBLXString
        {
            get { return _XBLXString; }
            set { _XBLXString = value; }
        }

        private string _StatusString;
        [DataMember]
        public string StatusString
        {
            get { return _StatusString; }
            set { _StatusString = value; }
        }

        private string _OrgName;
        [DataMember]
        public string OrgName
        {
            get { return _OrgName; }
            set { _OrgName = value; }
        }

        private bool isselected = false;
        [DataMember]
        public bool IsSelected
        {
            get { return isselected; }
            set { isselected = value; }
        }

        private string _Zu;
        [DataMember]
        public string Zu
        {
            get { return _Zu; }
            set { _Zu = value; }
        }

        private int _AnPaiID;
        [DataMember]
        public int AnPaiID
        {
            get { return _AnPaiID; }
            set { _AnPaiID = value; }
        }

        private string _DutyDes;
        [DataMember]
        public string DutyDes
        {
            get { return _DutyDes; }
            set { _DutyDes = value; }
        }
        /// <summary>
        /// 发布的时候看是发布的那种选拔类型的
        /// </summary>
        private string _FaBuType;
        [DataMember]
        public string FaBuType
        {
            get { return _FaBuType; }
            set { _FaBuType = value; }
        }
        private string _DutyLevel;
        [DataMember]
        public string DutyLevel
        {
            get { return _DutyLevel; }
            set { _DutyLevel = value; }
        }
        private string _DutyAttribute;
        [DataMember]
        public string DutyAttribute
        {
            get { return _DutyAttribute; }
            set { _DutyAttribute = value; }
        }

        /// <summary>
        /// 用于日程安排时
        /// </summary>
        private bool isselected1 = false;
        [DataMember]
        public bool IsSelected1
        {
            get { return isselected1; }
            set { isselected1 = value; }
        }

        private int _Year;
        [DataMember]
        public int Year
        {
            get { return _Year; }
            set { _Year = value; }
        }
        private bool _IsLocked;
        [DataMember]
        public bool IsLocked
        {
            get { return _IsLocked; }
            set { _IsLocked = value; }
        }
        private int _ExameID;
        [DataMember]
        public int ExameID
        {
            get { return _ExameID; }
            set { _ExameID = value; }
        }
        /// <summary>
        /// 科室
        /// </summary>
        private string _Department_Duty;
        [DataMember]
        public string Department_Duty
        {
            get { return _Department_Duty; }
            set { _Department_Duty = value; }
        }
        private DateTime? _ExameDate;
        [DataMember]
        public DateTime? ExameDate
        {
            get { return _ExameDate; }
            set { _ExameDate = value; }
        }
        private string _KaoShiStatus;
        [DataMember]
        public string KaoShiStatus
        {
            get { return _KaoShiStatus; }
            set { _KaoShiStatus = value; }
        }
        public static PublicOfficialSelectionModel FillEntity(DataRow dr)
        {
            PublicOfficialSelectionModel right = new PublicOfficialSelectionModel();
            if (dr.Table != null && dr.Table.Columns.Contains("ExameDate")) if (!string.IsNullOrEmpty(dr["ExameDate"].ToString())) right.ExameDate = (DateTime?)dr["ExameDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("ExameID")) if (!string.IsNullOrEmpty(dr["ExameID"].ToString())) right.ExameID = Convert.ToInt32(dr["ExameID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) right.Sec = Convert.ToInt32(dr["Sec"]);
            right.ID = (int)dr["ID"];
            right.OrgID = (int)dr["OrgID"];
            right.Department = dr["Department"] as string;
            right.Duty = dr["Duty"] as string;
            right.DutyDescription = dr["DutyDescription"] as string;
            right.PeopleCount = dr["PeopleCount"] as string;
            right.Education = dr["Education"] as string;
            right.Political = dr["Political"] as string;
            right.FaBuType = dr["FaBuType"] as string;
            right.DutyQualifications = dr["DutyQualifications"] as string;
            right.Memo = dr["Memo"] as string;
            right.Status = Convert.ToInt32(dr["Status"]);
            right.CheckMemo = dr["CheckMemo"] as string;
            right.OrgName = dr["OrgName"] as string;
            right.IsXDJL = Convert.ToBoolean(dr["IsXDJL"]);
            right.IsJZXXB = Convert.ToBoolean(dr["IsJZXXB"]);
            right.IsLocked = Convert.ToBoolean(dr["IsLocked"]);
            right.Year = Convert.ToInt32(dr["Year"]);
            right.DutyLevel = dr["DutyLevel"] as string;
            right.DutyAttribute = dr["DutyAttribute"] as string;
            if (right.IsXDJL == true) right.XBLXString += "选调交流,";
            if (right.IsJZXXB == true) right.XBLXString += "竞争性选拔,";
            if (dr.Table != null && dr.Table.Columns.Contains("KaoShiStatus")) right.KaoShiStatus = dr["KaoShiStatus"] as string;
            if (!string.IsNullOrEmpty(right.XBLXString))
                right.XBLXString = right.XBLXString.Substring(0, right.XBLXString.Length - 1);
            if (dr.Table != null && dr.Table.Columns.Contains("Department_Duty"))
                right.Department_Duty = dr["Department_Duty"] as string;
            switch(right.Status)
            {
                case 0:
                    right.StatusString = "未提交";
                    break;
                case 1:
                    right.StatusString = "已提交";
                    break;
                case 2:
                    right.StatusString = "已退回";
                    break;
                case 3:
                    right.StatusString = "已审核";
                    break;
                case 4:
                    right.StatusString = "已发布";
                    break;
            }
                
            return right;
        }

        public static PublicOfficialSelectionModel FillEntity1(DataRow dr)
        {
            PublicOfficialSelectionModel right = new PublicOfficialSelectionModel();
            if (dr.Table != null && dr.Table.Columns.Contains("ExameDate")) if (!string.IsNullOrEmpty(dr["ExameDate"].ToString())) right.ExameDate = (DateTime?)dr["ExameDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("ExameID")) if (!string.IsNullOrEmpty(dr["ExameID"].ToString())) right.ExameID = Convert.ToInt32(dr["ExameID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) right.Sec = Convert.ToInt32(dr["Sec"]);
            if (dr.Table != null && dr.Table.Columns.Contains("KaoShiStatus")) right.KaoShiStatus = dr["KaoShiStatus"] as string;
            right.ID = (int)dr["ID"];
            right.OrgID = (int)dr["OrgID"];
            if (!string.IsNullOrEmpty(dr["AnPaiID"].ToString())) right.AnPaiID = Convert.ToInt32(dr["AnPaiID"].ToString());
            right.Department = dr["Department"] as string;
            right.Duty = dr["Duty"] as string;
            right.DutyDescription = dr["DutyDescription"] as string;
            right.PeopleCount = dr["PeopleCount"] as string;
            right.Education = dr["Education"] as string;
            right.Political = dr["Political"] as string;
            right.Zu = dr["Zu"] as string;
            right.DutyQualifications = dr["DutyQualifications"] as string;
            right.Memo = dr["Memo"] as string;
            right.Status = Convert.ToInt32(dr["Status"]);
            right.CheckMemo = dr["CheckMemo"] as string;
            right.OrgName = dr["OrgName"] as string;
            right.IsXDJL = Convert.ToBoolean(dr["IsXDJL"]);
            right.IsJZXXB = Convert.ToBoolean(dr["IsJZXXB"]);
            right.FaBuType = dr["FaBuType"] as string;
            right.Year = Convert.ToInt32(dr["Year"]);
            right.IsLocked = Convert.ToBoolean(dr["IsLocked"]);
            if (right.IsXDJL == true) right.XBLXString += "选调交流,";
            if (right.IsJZXXB == true) right.XBLXString += "竞争性选拔,";
            if (!string.IsNullOrEmpty(right.XBLXString))
                right.XBLXString = right.XBLXString.Substring(0, right.XBLXString.Length - 1);
            if (dr.Table != null && dr.Table.Columns.Contains("Department_Duty"))
                right.Department_Duty = dr["Department_Duty"] as string;
            switch (right.Status)
            {
                case 0:
                    right.StatusString = "未提交";
                    break;
                case 1:
                    right.StatusString = "已提交";
                    break;
                case 2:
                    right.StatusString = "已退回";
                    break;
                case 3:
                    right.StatusString = "已审核";
                    break;
                case 4:
                    right.StatusString = "已发布";
                    break;
            }

            return right;
        }
    }
}
